<?php


namespace app\common\model\committee;


use think\Model;

class CommitteeMemberModel extends Model
{
    protected $name = 'committee_member';

    /**
     * 获取列表
     * @param string $cid 分类ID
     * @return array
     */
    public function getPageList($cid, $user_id, $page, $limit): array
    {
        try {
            $where = [
                'status' => 1
            ];
            if(!empty($cid)) {
                $where['cat_id'] = $cid;
            }
            $field = 'id,cat_id,title,desc,mobile,image,address,lat,lng';
            $order = [
                'weigh' => 'asc',
            ];
            $list = $this
                ->where($where)
                ->field($field)
                ->order($order)
                ->paginate($limit, false, ['page' => $page]);
            foreach ($list as $row) {
                $row->image = wdsxh_full_url($row->image);
//                $row->desc = str_replace(array("\n", "\r\n"), '<br/>', $row->desc);
            }
            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => $list
            ];
        }catch (\Exception $e) {
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => []
            ];
        }
    }

}